{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "ecg_age_fratal_analysis calculates linear correlation between implemented fractal measures and age clases. the output is a dataframe in the form: ecg derivations x fractal measures, containig the values of the linear correlation"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "normal_ecg_age = pd.read_pickle('normal_ecg_age.pickle')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ECG_ID</th>\n",
       "      <th>Age</th>\n",
       "      <th>Age_class</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A00002</td>\n",
       "      <td>32</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   ECG_ID  Age  Age_class\n",
       "0  A00002   32          2"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "normal_ecg_age.head(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Katz"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>I_Katz</th>\n",
       "      <th>II_Katz</th>\n",
       "      <th>III_Katz</th>\n",
       "      <th>aVR_Katz</th>\n",
       "      <th>aVL_Katz</th>\n",
       "      <th>aVF_Katz</th>\n",
       "      <th>V1_Katz</th>\n",
       "      <th>V2_Katz</th>\n",
       "      <th>V3_Katz</th>\n",
       "      <th>V4_Katz</th>\n",
       "      <th>V5_Katz</th>\n",
       "      <th>V6_Katz</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A00002</td>\n",
       "      <td>1.749023</td>\n",
       "      <td>1.694336</td>\n",
       "      <td>1.697266</td>\n",
       "      <td>1.713867</td>\n",
       "      <td>1.860352</td>\n",
       "      <td>1.668945</td>\n",
       "      <td>1.674805</td>\n",
       "      <td>1.729492</td>\n",
       "      <td>1.897461</td>\n",
       "      <td>1.749023</td>\n",
       "      <td>1.689453</td>\n",
       "      <td>1.651367</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       ID    I_Katz   II_Katz  III_Katz  aVR_Katz  aVL_Katz  aVF_Katz  \\\n",
       "0  A00002  1.749023  1.694336  1.697266  1.713867  1.860352  1.668945   \n",
       "\n",
       "    V1_Katz   V2_Katz   V3_Katz   V4_Katz   V5_Katz   V6_Katz  \n",
       "0  1.674805  1.729492  1.897461  1.749023  1.689453  1.651367  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "normal_ecg_katz = pd.read_pickle('normal_ecg_katz.pickle')\n",
    "normal_ecg_katz.head(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "normal_ecg_katz_ID = normal_ecg_katz.drop('ID', axis=1)\n",
    "linear_corr_age_fractal = normal_ecg_katz_ID.corrwith(normal_ecg_age['Age_class'], axis=0, drop=False, method='pearson')\n",
    "linear_corr_age_fractal.reset_index(drop=True, inplace=True)\n",
    "linear_corr_age_fractal.name = 'Katz'\n",
    "linear_corr_age_fractal.index = ['I', 'II', 'III', 'aVR', 'aVL', 'aVF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6']\n",
    "linear_corr_age_fractal_dataframe = pd.DataFrame(data = linear_corr_age_fractal)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Katz</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>-0.089548</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>II</th>\n",
       "      <td>0.140622</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>III</th>\n",
       "      <td>0.117575</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVR</th>\n",
       "      <td>0.043645</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVL</th>\n",
       "      <td>-0.037227</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVF</th>\n",
       "      <td>0.185209</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V1</th>\n",
       "      <td>0.018317</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V2</th>\n",
       "      <td>-0.012784</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V3</th>\n",
       "      <td>-0.086127</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V4</th>\n",
       "      <td>-0.080300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V5</th>\n",
       "      <td>-0.073193</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V6</th>\n",
       "      <td>-0.018007</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         Katz\n",
       "I   -0.089548\n",
       "II   0.140622\n",
       "III  0.117575\n",
       "aVR  0.043645\n",
       "aVL -0.037227\n",
       "aVF  0.185209\n",
       "V1   0.018317\n",
       "V2  -0.012784\n",
       "V3  -0.086127\n",
       "V4  -0.080300\n",
       "V5  -0.073193\n",
       "V6  -0.018007"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "linear_corr_age_fractal_dataframe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "LL"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>I_LL</th>\n",
       "      <th>II_LL</th>\n",
       "      <th>III_LL</th>\n",
       "      <th>aVR_LL</th>\n",
       "      <th>aVL_LL</th>\n",
       "      <th>aVF_LL</th>\n",
       "      <th>V1_LL</th>\n",
       "      <th>V2_LL</th>\n",
       "      <th>V3_LL</th>\n",
       "      <th>V4_LL</th>\n",
       "      <th>V5_LL</th>\n",
       "      <th>V6_LL</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A00002</td>\n",
       "      <td>0.007881</td>\n",
       "      <td>0.008415</td>\n",
       "      <td>0.003286</td>\n",
       "      <td>0.007881</td>\n",
       "      <td>0.004463</td>\n",
       "      <td>0.005203</td>\n",
       "      <td>0.011002</td>\n",
       "      <td>0.021942</td>\n",
       "      <td>0.014366</td>\n",
       "      <td>0.013756</td>\n",
       "      <td>0.013229</td>\n",
       "      <td>0.008461</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       ID      I_LL     II_LL    III_LL    aVR_LL    aVL_LL    aVF_LL  \\\n",
       "0  A00002  0.007881  0.008415  0.003286  0.007881  0.004463  0.005203   \n",
       "\n",
       "      V1_LL     V2_LL     V3_LL     V4_LL     V5_LL     V6_LL  \n",
       "0  0.011002  0.021942  0.014366  0.013756  0.013229  0.008461  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "normal_ecg_ll = pd.read_pickle('normal_ecg_ll.pickle')\n",
    "normal_ecg_ll.head(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "normal_ecg_ll_ID = normal_ecg_ll.drop('ID', axis=1)\n",
    "linear_corr_age_fractal = normal_ecg_ll_ID.corrwith(normal_ecg_age['Age_class'], axis=0, drop=False, method='pearson')\n",
    "linear_corr_age_fractal.reset_index(drop=True, inplace=True)\n",
    "linear_corr_age_fractal.name = 'LL'\n",
    "linear_corr_age_fractal.index = ['I', 'II', 'III', 'aVR', 'aVL', 'aVF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Katz</th>\n",
       "      <th>LL</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>-0.089548</td>\n",
       "      <td>0.105419</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>II</th>\n",
       "      <td>0.140622</td>\n",
       "      <td>-0.206025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>III</th>\n",
       "      <td>0.117575</td>\n",
       "      <td>-0.118168</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVR</th>\n",
       "      <td>0.043645</td>\n",
       "      <td>-0.061787</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVL</th>\n",
       "      <td>-0.037227</td>\n",
       "      <td>0.071852</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVF</th>\n",
       "      <td>0.185209</td>\n",
       "      <td>-0.224234</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V1</th>\n",
       "      <td>0.018317</td>\n",
       "      <td>-0.031915</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V2</th>\n",
       "      <td>-0.012784</td>\n",
       "      <td>-0.014712</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V3</th>\n",
       "      <td>-0.086127</td>\n",
       "      <td>-0.003325</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V4</th>\n",
       "      <td>-0.080300</td>\n",
       "      <td>-0.008985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V5</th>\n",
       "      <td>-0.073193</td>\n",
       "      <td>-0.007005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V6</th>\n",
       "      <td>-0.018007</td>\n",
       "      <td>-0.028328</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         Katz        LL\n",
       "I   -0.089548  0.105419\n",
       "II   0.140622 -0.206025\n",
       "III  0.117575 -0.118168\n",
       "aVR  0.043645 -0.061787\n",
       "aVL -0.037227  0.071852\n",
       "aVF  0.185209 -0.224234\n",
       "V1   0.018317 -0.031915\n",
       "V2  -0.012784 -0.014712\n",
       "V3  -0.086127 -0.003325\n",
       "V4  -0.080300 -0.008985\n",
       "V5  -0.073193 -0.007005\n",
       "V6  -0.018007 -0.028328"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "linear_corr_age_fractal_dataframe = pd.concat([linear_corr_age_fractal_dataframe, linear_corr_age_fractal], axis=1)\n",
    "linear_corr_age_fractal_dataframe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "NLD"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>I_NLD</th>\n",
       "      <th>II_NLD</th>\n",
       "      <th>III_NLD</th>\n",
       "      <th>aVR_NLD</th>\n",
       "      <th>aVL_NLD</th>\n",
       "      <th>aVF_NLD</th>\n",
       "      <th>V1_NLD</th>\n",
       "      <th>V2_NLD</th>\n",
       "      <th>V3_NLD</th>\n",
       "      <th>V4_NLD</th>\n",
       "      <th>V5_NLD</th>\n",
       "      <th>V6_NLD</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A00002</td>\n",
       "      <td>0.052124</td>\n",
       "      <td>0.044067</td>\n",
       "      <td>0.042877</td>\n",
       "      <td>0.046906</td>\n",
       "      <td>0.061462</td>\n",
       "      <td>0.04187</td>\n",
       "      <td>0.037781</td>\n",
       "      <td>0.037659</td>\n",
       "      <td>0.046539</td>\n",
       "      <td>0.047852</td>\n",
       "      <td>0.043915</td>\n",
       "      <td>0.03949</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       ID     I_NLD    II_NLD   III_NLD   aVR_NLD   aVL_NLD  aVF_NLD  \\\n",
       "0  A00002  0.052124  0.044067  0.042877  0.046906  0.061462  0.04187   \n",
       "\n",
       "     V1_NLD    V2_NLD    V3_NLD    V4_NLD    V5_NLD   V6_NLD  \n",
       "0  0.037781  0.037659  0.046539  0.047852  0.043915  0.03949  "
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "normal_ecg_nld = pd.read_pickle('normal_ecg_nld.pickle')\n",
    "normal_ecg_nld.head(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "normal_ecg_nld_ID = normal_ecg_nld.drop('ID', axis=1)\n",
    "linear_corr_age_fractal = normal_ecg_nld_ID.corrwith(normal_ecg_age['Age_class'], axis=0, drop=False, method='pearson')\n",
    "linear_corr_age_fractal.reset_index(drop=True, inplace=True)\n",
    "linear_corr_age_fractal.name = 'NLD'\n",
    "linear_corr_age_fractal.index = ['I', 'II', 'III', 'aVR', 'aVL', 'aVF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Katz</th>\n",
       "      <th>LL</th>\n",
       "      <th>NLD</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>-0.089548</td>\n",
       "      <td>0.105419</td>\n",
       "      <td>0.069728</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>II</th>\n",
       "      <td>0.140622</td>\n",
       "      <td>-0.206025</td>\n",
       "      <td>0.113973</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>III</th>\n",
       "      <td>0.117575</td>\n",
       "      <td>-0.118168</td>\n",
       "      <td>0.091657</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVR</th>\n",
       "      <td>0.043645</td>\n",
       "      <td>-0.061787</td>\n",
       "      <td>0.101115</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVL</th>\n",
       "      <td>-0.037227</td>\n",
       "      <td>0.071852</td>\n",
       "      <td>0.038812</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVF</th>\n",
       "      <td>0.185209</td>\n",
       "      <td>-0.224234</td>\n",
       "      <td>0.123893</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V1</th>\n",
       "      <td>0.018317</td>\n",
       "      <td>-0.031915</td>\n",
       "      <td>0.066411</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V2</th>\n",
       "      <td>-0.012784</td>\n",
       "      <td>-0.014712</td>\n",
       "      <td>0.119444</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V3</th>\n",
       "      <td>-0.086127</td>\n",
       "      <td>-0.003325</td>\n",
       "      <td>0.099049</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V4</th>\n",
       "      <td>-0.080300</td>\n",
       "      <td>-0.008985</td>\n",
       "      <td>0.088495</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V5</th>\n",
       "      <td>-0.073193</td>\n",
       "      <td>-0.007005</td>\n",
       "      <td>0.064521</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V6</th>\n",
       "      <td>-0.018007</td>\n",
       "      <td>-0.028328</td>\n",
       "      <td>0.050865</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         Katz        LL       NLD\n",
       "I   -0.089548  0.105419  0.069728\n",
       "II   0.140622 -0.206025  0.113973\n",
       "III  0.117575 -0.118168  0.091657\n",
       "aVR  0.043645 -0.061787  0.101115\n",
       "aVL -0.037227  0.071852  0.038812\n",
       "aVF  0.185209 -0.224234  0.123893\n",
       "V1   0.018317 -0.031915  0.066411\n",
       "V2  -0.012784 -0.014712  0.119444\n",
       "V3  -0.086127 -0.003325  0.099049\n",
       "V4  -0.080300 -0.008985  0.088495\n",
       "V5  -0.073193 -0.007005  0.064521\n",
       "V6  -0.018007 -0.028328  0.050865"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "linear_corr_age_fractal_dataframe = pd.concat([linear_corr_age_fractal_dataframe, linear_corr_age_fractal], axis=1)\n",
    "linear_corr_age_fractal_dataframe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Petrosian"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>I_Pt</th>\n",
       "      <th>II_Pt</th>\n",
       "      <th>III_Pt</th>\n",
       "      <th>aVR_Pt</th>\n",
       "      <th>aVL_Pt</th>\n",
       "      <th>aVF_Pt</th>\n",
       "      <th>V1_Pt</th>\n",
       "      <th>V2_Pt</th>\n",
       "      <th>V3_Pt</th>\n",
       "      <th>V4_Pt</th>\n",
       "      <th>V5_Pt</th>\n",
       "      <th>V6_Pt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A00002</td>\n",
       "      <td>1.005998</td>\n",
       "      <td>1.006791</td>\n",
       "      <td>1.007079</td>\n",
       "      <td>1.006467</td>\n",
       "      <td>1.005835</td>\n",
       "      <td>1.007741</td>\n",
       "      <td>1.005726</td>\n",
       "      <td>1.003859</td>\n",
       "      <td>1.003336</td>\n",
       "      <td>1.003777</td>\n",
       "      <td>1.004125</td>\n",
       "      <td>1.005763</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       ID      I_Pt     II_Pt    III_Pt    aVR_Pt    aVL_Pt    aVF_Pt  \\\n",
       "0  A00002  1.005998  1.006791  1.007079  1.006467  1.005835  1.007741   \n",
       "\n",
       "      V1_Pt     V2_Pt     V3_Pt     V4_Pt     V5_Pt     V6_Pt  \n",
       "0  1.005726  1.003859  1.003336  1.003777  1.004125  1.005763  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "normal_ecg_pt = pd.read_pickle('normal_ecg_petrosian.pickle')\n",
    "normal_ecg_pt.head(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "normal_ecg_pt_ID = normal_ecg_pt.drop('ID', axis=1)\n",
    "linear_corr_age_fractal = normal_ecg_pt_ID.corrwith(normal_ecg_age['Age_class'], axis=0, drop=False, method='pearson')\n",
    "linear_corr_age_fractal.reset_index(drop=True, inplace=True)\n",
    "linear_corr_age_fractal.name = 'Petrosian'\n",
    "linear_corr_age_fractal.index = ['I', 'II', 'III', 'aVR', 'aVL', 'aVF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Katz</th>\n",
       "      <th>LL</th>\n",
       "      <th>NLD</th>\n",
       "      <th>Petrosian</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>-0.089548</td>\n",
       "      <td>0.105419</td>\n",
       "      <td>0.069728</td>\n",
       "      <td>0.086680</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>II</th>\n",
       "      <td>0.140622</td>\n",
       "      <td>-0.206025</td>\n",
       "      <td>0.113973</td>\n",
       "      <td>0.052930</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>III</th>\n",
       "      <td>0.117575</td>\n",
       "      <td>-0.118168</td>\n",
       "      <td>0.091657</td>\n",
       "      <td>0.026613</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVR</th>\n",
       "      <td>0.043645</td>\n",
       "      <td>-0.061787</td>\n",
       "      <td>0.101115</td>\n",
       "      <td>0.080484</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVL</th>\n",
       "      <td>-0.037227</td>\n",
       "      <td>0.071852</td>\n",
       "      <td>0.038812</td>\n",
       "      <td>0.049384</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVF</th>\n",
       "      <td>0.185209</td>\n",
       "      <td>-0.224234</td>\n",
       "      <td>0.123893</td>\n",
       "      <td>0.032632</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V1</th>\n",
       "      <td>0.018317</td>\n",
       "      <td>-0.031915</td>\n",
       "      <td>0.066411</td>\n",
       "      <td>0.053236</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V2</th>\n",
       "      <td>-0.012784</td>\n",
       "      <td>-0.014712</td>\n",
       "      <td>0.119444</td>\n",
       "      <td>0.074345</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V3</th>\n",
       "      <td>-0.086127</td>\n",
       "      <td>-0.003325</td>\n",
       "      <td>0.099049</td>\n",
       "      <td>0.060887</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V4</th>\n",
       "      <td>-0.080300</td>\n",
       "      <td>-0.008985</td>\n",
       "      <td>0.088495</td>\n",
       "      <td>0.059174</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V5</th>\n",
       "      <td>-0.073193</td>\n",
       "      <td>-0.007005</td>\n",
       "      <td>0.064521</td>\n",
       "      <td>0.052984</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V6</th>\n",
       "      <td>-0.018007</td>\n",
       "      <td>-0.028328</td>\n",
       "      <td>0.050865</td>\n",
       "      <td>0.033985</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         Katz        LL       NLD  Petrosian\n",
       "I   -0.089548  0.105419  0.069728   0.086680\n",
       "II   0.140622 -0.206025  0.113973   0.052930\n",
       "III  0.117575 -0.118168  0.091657   0.026613\n",
       "aVR  0.043645 -0.061787  0.101115   0.080484\n",
       "aVL -0.037227  0.071852  0.038812   0.049384\n",
       "aVF  0.185209 -0.224234  0.123893   0.032632\n",
       "V1   0.018317 -0.031915  0.066411   0.053236\n",
       "V2  -0.012784 -0.014712  0.119444   0.074345\n",
       "V3  -0.086127 -0.003325  0.099049   0.060887\n",
       "V4  -0.080300 -0.008985  0.088495   0.059174\n",
       "V5  -0.073193 -0.007005  0.064521   0.052984\n",
       "V6  -0.018007 -0.028328  0.050865   0.033985"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "linear_corr_age_fractal_dataframe = pd.concat([linear_corr_age_fractal_dataframe, linear_corr_age_fractal], axis=1)\n",
    "linear_corr_age_fractal_dataframe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Sevcik"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ID</th>\n",
       "      <th>I_Sk</th>\n",
       "      <th>II_Sk</th>\n",
       "      <th>III_Sk</th>\n",
       "      <th>aVR_Sk</th>\n",
       "      <th>aVL_Sk</th>\n",
       "      <th>aVF_Sk</th>\n",
       "      <th>V1_Sk</th>\n",
       "      <th>V2_Sk</th>\n",
       "      <th>V3_Sk</th>\n",
       "      <th>V4_Sk</th>\n",
       "      <th>V5_Sk</th>\n",
       "      <th>V6_Sk</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>A00002</td>\n",
       "      <td>1.378269</td>\n",
       "      <td>1.372465</td>\n",
       "      <td>1.357965</td>\n",
       "      <td>1.378887</td>\n",
       "      <td>1.375656</td>\n",
       "      <td>1.363695</td>\n",
       "      <td>1.356642</td>\n",
       "      <td>1.358644</td>\n",
       "      <td>1.380744</td>\n",
       "      <td>1.371294</td>\n",
       "      <td>1.363425</td>\n",
       "      <td>1.350977</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       ID      I_Sk     II_Sk    III_Sk    aVR_Sk    aVL_Sk    aVF_Sk  \\\n",
       "0  A00002  1.378269  1.372465  1.357965  1.378887  1.375656  1.363695   \n",
       "\n",
       "      V1_Sk     V2_Sk     V3_Sk     V4_Sk     V5_Sk     V6_Sk  \n",
       "0  1.356642  1.358644  1.380744  1.371294  1.363425  1.350977  "
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "normal_ecg_sk = pd.read_pickle('normal_ecg_sevcik.pickle')\n",
    "normal_ecg_sk.head(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "normal_ecg_sk_ID = normal_ecg_sk.drop('ID', axis=1)\n",
    "linear_corr_age_fractal = normal_ecg_sk_ID.corrwith(normal_ecg_age['Age_class'], axis=0, drop=False, method='pearson')\n",
    "linear_corr_age_fractal.reset_index(drop=True, inplace=True)\n",
    "linear_corr_age_fractal.name = 'Sevcik'\n",
    "linear_corr_age_fractal.index = ['I', 'II', 'III', 'aVR', 'aVL', 'aVF', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Katz</th>\n",
       "      <th>LL</th>\n",
       "      <th>NLD</th>\n",
       "      <th>Petrosian</th>\n",
       "      <th>Sevcik</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>-0.089548</td>\n",
       "      <td>0.105419</td>\n",
       "      <td>0.069728</td>\n",
       "      <td>0.086680</td>\n",
       "      <td>-0.037923</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>II</th>\n",
       "      <td>0.140622</td>\n",
       "      <td>-0.206025</td>\n",
       "      <td>0.113973</td>\n",
       "      <td>0.052930</td>\n",
       "      <td>0.117339</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>III</th>\n",
       "      <td>0.117575</td>\n",
       "      <td>-0.118168</td>\n",
       "      <td>0.091657</td>\n",
       "      <td>0.026613</td>\n",
       "      <td>0.083276</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVR</th>\n",
       "      <td>0.043645</td>\n",
       "      <td>-0.061787</td>\n",
       "      <td>0.101115</td>\n",
       "      <td>0.080484</td>\n",
       "      <td>0.055085</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVL</th>\n",
       "      <td>-0.037227</td>\n",
       "      <td>0.071852</td>\n",
       "      <td>0.038812</td>\n",
       "      <td>0.049384</td>\n",
       "      <td>-0.025820</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>aVF</th>\n",
       "      <td>0.185209</td>\n",
       "      <td>-0.224234</td>\n",
       "      <td>0.123893</td>\n",
       "      <td>0.032632</td>\n",
       "      <td>0.148094</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V1</th>\n",
       "      <td>0.018317</td>\n",
       "      <td>-0.031915</td>\n",
       "      <td>0.066411</td>\n",
       "      <td>0.053236</td>\n",
       "      <td>0.026705</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V2</th>\n",
       "      <td>-0.012784</td>\n",
       "      <td>-0.014712</td>\n",
       "      <td>0.119444</td>\n",
       "      <td>0.074345</td>\n",
       "      <td>-0.054273</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V3</th>\n",
       "      <td>-0.086127</td>\n",
       "      <td>-0.003325</td>\n",
       "      <td>0.099049</td>\n",
       "      <td>0.060887</td>\n",
       "      <td>-0.097969</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V4</th>\n",
       "      <td>-0.080300</td>\n",
       "      <td>-0.008985</td>\n",
       "      <td>0.088495</td>\n",
       "      <td>0.059174</td>\n",
       "      <td>-0.110047</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V5</th>\n",
       "      <td>-0.073193</td>\n",
       "      <td>-0.007005</td>\n",
       "      <td>0.064521</td>\n",
       "      <td>0.052984</td>\n",
       "      <td>-0.090801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>V6</th>\n",
       "      <td>-0.018007</td>\n",
       "      <td>-0.028328</td>\n",
       "      <td>0.050865</td>\n",
       "      <td>0.033985</td>\n",
       "      <td>-0.035117</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         Katz        LL       NLD  Petrosian    Sevcik\n",
       "I   -0.089548  0.105419  0.069728   0.086680 -0.037923\n",
       "II   0.140622 -0.206025  0.113973   0.052930  0.117339\n",
       "III  0.117575 -0.118168  0.091657   0.026613  0.083276\n",
       "aVR  0.043645 -0.061787  0.101115   0.080484  0.055085\n",
       "aVL -0.037227  0.071852  0.038812   0.049384 -0.025820\n",
       "aVF  0.185209 -0.224234  0.123893   0.032632  0.148094\n",
       "V1   0.018317 -0.031915  0.066411   0.053236  0.026705\n",
       "V2  -0.012784 -0.014712  0.119444   0.074345 -0.054273\n",
       "V3  -0.086127 -0.003325  0.099049   0.060887 -0.097969\n",
       "V4  -0.080300 -0.008985  0.088495   0.059174 -0.110047\n",
       "V5  -0.073193 -0.007005  0.064521   0.052984 -0.090801\n",
       "V6  -0.018007 -0.028328  0.050865   0.033985 -0.035117"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "linear_corr_age_fractal_dataframe = pd.concat([linear_corr_age_fractal_dataframe, linear_corr_age_fractal], axis=1)\n",
    "linear_corr_age_fractal_dataframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "linear_corr_age_fractal_dataframe.to_pickle('linear_corr_age_fractal.pickle')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.8.5 ('ecg_biomarkers': venv)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "d39f5264c2f26cb0964d5a98dbbf3a9d2bc7301339817434e4f0ffa82f5f047f"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
